package top.continew.minithreadpool.concurrent;

/**
 * 线程池状态管理
 */
public class ThreadPoolState {

    // 运行状态
    public static final int RUNNING = 0;
    // 关闭状态
    public static final int SHUTDOWN = 1;
    // 停止状态
    public static final int STOP = 2;
    // 终止状态
    public static final int TERMINATED = 3;

    private volatile int state = RUNNING;

    public int getState() {
        return state;
    }

    public void setState(int newState) {
        this.state = newState;
    }

    public boolean isRunning() {
        return state == RUNNING;
    }

    public boolean isShutdown() {
        return state >= SHUTDOWN;
    }

    public boolean isStop() {
        return state >= STOP;
    }

    public boolean isTerminated() {
        return state == TERMINATED;
    }
}
